package IO_study.charStream;

import java.io.FileReader;
import java.io.Reader;

/**
 * 文件输入流,以字符数组来读取
 * 小结:
 *      字符流按照字符数组循环读取数据,可以解决中文乱码问题
 */
public class FileReaderDemo2 {
    public static void main(String[] args) throws Exception{
        Reader r = new FileReader("Java-basic/src/IO_study/data.txt");

        char[] buffer = new char[1024]; // 1k字符
        int len;
        while ((len = r.read(buffer)) != -1){
            // 读取多少倒多少
            String rs = new String(buffer,0,len);
            System.out.print(rs);
        }

    }
}
